package com.xuecheng.content.convert;

import com.xuecheng.api.content.model.dto.CourseBaseDTO;
import com.xuecheng.api.content.model.vo.CourseBaseVO;
import com.xuecheng.content.entity.CourseBase;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;
import org.mybatis.spring.annotation.MapperScan;

import java.util.List;

//TODO:对象属性转换器,po转DTO
@Mapper
public interface CourseBaseConvert {
    CourseBaseConvert INSTANCE = Mappers.getMapper(CourseBaseConvert.class);
    //po转DTO
    //TODO:对于不对应的字段,可以用注解@Mapping指定,多个用
    /*
      @Mappings({
            @Mapping(source = "id",target = "courseBaseId")
            .......
    })
    指定
    * */
    @Mapping(source = "id",target = "courseBaseId")
//    @Mappings({
//            @Mapping(source = "id",target = "courseBaseId")
//    })
    CourseBaseDTO entity2Dto(CourseBase courseBase);

    CourseBase dto2Entity(CourseBaseDTO courseBaseDTO);

    CourseBaseDTO vo2Dto(CourseBaseVO courseBaseVO);


//TODO:集合的转换方法依赖单个的转换方法,上面的也必不可少
    List<CourseBaseDTO> entitys2Dtos(List<CourseBase> courseBase);
}
